<!--
    合同信息插件
    参数：对象类型
    Obj: {
                roleType: 角色类型,（枚举类型：经销商:SP ）
                contractNo: 合同号
            }

-->
<template>
    <div class="basis-info" style="width: 100%;">
        <Form ref="formData" :model="formData" :label-width="100">
            <Row>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="申请编号">
                        <Input type="text" v-model="formData.applyNo" disabled/>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="合同号" v-if="!this.Obj.roleType">
                        <Input type="text" v-model="formData.contractNo" disabled/>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="客户姓名">
                        <Input type="text" v-model="formData.basicCustBaseInfo.custName" disabled/>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="证件号码">
                        <Input type="text" v-model="formData.basicCustBaseInfo.certNo" disabled/>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="联系方式">
                        <Input type="text" v-model="formData.basicCustBaseInfo.phone" disabled/>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="渠道归属" v-if="!this.Obj.roleType">
                        <Select v-model="formData.channelBelong" placeholder disabled>
                            <Option v-for="item in dataDic.channelBelong" :value="item.value"
                                    :key="item.value" :label="item.title">
                                {{ item.title }}
                            </Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="合作商" v-if="!this.Obj.roleType">
                        <Input type="text" v-model="formData.channelFullName" disabled/>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="合同状态" v-if="!this.Obj.roleType">
                        <Select v-model="formData.contractStatus" placeholder disabled>
                            <Option v-for="item in dataDic.contractStatus" :value="item.value"
                                    :key="item.value" :label="item.title">
                                {{ item.title }}
                            </Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="放款模式">
                        <Select v-model="formData.loanModel" placeholder disabled>
                            <Option v-for="item in dataDic.loanModel" :value="item.value"
                                    :key="item.value" :label="item.title">
                                {{ item.title }}
                            </Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="合同激活时间">
                        <!-- <Input type="date" v-model="formData.startDate" disabled/> -->
                        <Input type="text" v-model="formData.startDate" disabled></Input>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="合同终止时间">
                        <Input type="text" format="yyyy-MM-dd" v-model="formData.endDate" disabled></Input>
                    </FormItem>
                </Col>
                <Col v-if="type !== 'cancelContract'" :xs="24" :md="12" :xl="6">
                    <FormItem label="逾期天数" v-if="!this.Obj.roleType">
                        <Input type="text" v-model="formData.currentAbsoluteOverdue" disabled/>
                    </FormItem>
                </Col>
                <Col :xs="24" :md="12" :xl="6">
                    <FormItem label="上次还款日期" v-if="!this.Obj.roleType">
                        <Input type="text" format="yyyy-MM-dd" v-model="formData.actualPaymentDate" disabled/>
                    </FormItem>
                </Col>
            </Row>
        </Form>
    </div>
</template>
<script>
    import {
        getBasicInfo,
        getCustInfo
    } from "_p/basic/api/contract/common/contract-info/contract-info";
    import {deepClone} from "@/libs/utils/ObjectClone";
    import {getByTypes} from "_p/basic/api/admin/datadic";
    import {channelType} from "_p/basic/api/contract/channel-type/channel-type";

    export default {
        // 合同信息
        name: "contractInfo",
        props: {
            //对象参数包含：合同号码、角色类型
            Obj: {
                type: Object,
                required: true
            },
            type: {
                type: String,
            }
        },
        data() {
            return {
                formData: {
                    basicMainInfo: {},
                    basicCustBaseInfo: {},
                    basicCustContactDetails: {},
                    basicChannelInfo: {},
                    basicDebitInfo: {
                        currentAbsoluteOverdue: 0
                    },
                    actualPaymentDate: ""
                },
                dataDic: {
                    loanModel: [],
                    channelType: [],
                    contractStatus: []
                }
            };
        },
        mounted() {
            this.init();
        },
        methods: {
            init() {
                this.getBasicInfo();
                this.getByDic();
                this.getCustInfo();
            },
            getByDic() {
                let arr = ["loanModel", "channelBelong", "contractStatus"];
                getByTypes(arr).then(res => {
                    if (res.code === "0000") {
                        this.dataDic = deepClone(res.data);
                    }
                });
            },
            getBasicInfo() {
                if (!this.Obj.contractNo) return;

                getBasicInfo(this.Obj.contractNo, channelType(this.$route.meta.params)).then(res => {
                    if (res.code === "0000") {
                        this.formData = Object.assign({}, this.formData, res.data);
                    }
                });
            },
            getCustInfo() {
                if (!this.Obj.contractNo) return;

                getCustInfo(this.Obj.contractNo, channelType(this.$route.meta.params)).then(res => {
                    if (res.code === "0000") {
                        this.formData.basicCustBaseInfo = Object.assign({}, this.formData.basicCustBaseInfo, res.data);
                        this.$emit('getChildData',res.data)
                    }
                });
            },
        }
    };
</script>
<style scoped>
    .basis-info >>> .ivu-input[disabled] {
        color: black;
    }

    .basis-info >>> .ivu-select-disabled .ivu-select-selected-value {
        color: #515a6e;
    }

    .basis-info >>> .ivu-input-number-input[disabled] {
        color: black;
    }
</style>
